<template>
  <div id="stopdialog">
    <commonformdialog
      :isshowDialogs="isshowDialog"
      :isshowconfirmbtn="false"
      :dialogWidth="'25%'"
      :enterTitle="false"
      :isshowimportTitle="false"
      :dialogTitle="'驳回'"
      @closetextDialog="closetextDialog"
      @confirmbtn='confirmbtn'
      :topHeight='"25vh"'
    >

    <!-- 表单区域 -->
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px" label-position="top">
      <el-form-item label="请输入驳回理由" prop="back_info">
        <el-input v-model="formData.back_info" type="textarea" placeholder="请输入请输入驳回理由"
          :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
      </el-form-item>
    </el-form>



    </commonformdialog>
  </div>
</template>

<script>
//引入弹窗
import commonformdialog from '@/components/commondialog/commondialog'
//api
//api
import {approval} from '@/api/finance'
export default {
  data() {
    return {
    formData: {
            back_info: undefined,
          },
          rules: {
            back_info: [{
              required: true,
              message: '请输入驳回理由！',
              trigger: 'blur'
            }],
          },
    }
  },
  components: {
    commonformdialog,
  },
  props: {
    //是否显示弹窗
    isshowDialog: {
      type: Boolean,
      default: false,
    },
    //费用id
    priceparams:{
      type:Object,
      default:()=>{
        return {}
      }
    }
  },
  methods:{
      //关闭弹窗
    closetextDialog() {
      this.$refs['elForm'].resetFields()
      this.$emit('closetextDialog')
    },
    //点击确认
    confirmbtn(){
        this.$refs['elForm'].validate(async valid => {
        if (!valid) return
        let params = {
          id:this.priceparams.id,
          status:2,
          back_info:this.formData.back_info
        }
        let data = await approval(params)
        if(data.code=='0000'){
          this.$message.success('驳回成功！')
          //刷新列表 关闭弹窗
          this.$emit('refresh')
          //清空表单
          this.$refs['elForm'].resetFields()
        }
      })

    }
  }
}
</script>

<style scoped lang='scss'>
::v-deep{
  .el-form{
    padding-right: 0px !important;
  }
}
</style>
